package interviewpreparationkit.dictionary


import org.junit.jupiter.api.Test
import redirectSystemIn
import redirectSystemOut
import java.util.*

class CountTripletsTests {
    @Test
    fun countTripletsTest() {
        redirectSystemIn(this.javaClass) {
            val scan = Scanner(System.`in`)

            redirectSystemOut {
                while (scan.hasNextLine()) {
                    val nr = scan.nextLine()!!.trimEnd().split(" ")

                    val n = nr[0].toInt()

                    val r = nr[1].toLong()

                    val arr = scan.nextLine()!!.trimEnd().split(" ").map { it.toLong() }.toTypedArray()

                    val ans = countTriplets(arr, r)

                    println(ans)

                    it.add(scan.nextLine().trim())
                }
            }
        }
    }
}